#ifndef __syntax_entry_H__
#define __syntax_entry_H__

#include "syntax_base.h"
#include "syntax_compound.h"

#include <string>
using namespace std;

namespace syntax_analysis
{

	class syntax_entry : public syntax
	{
	// construct
	public:
		syntax_entry() : syntax()
		{
			m_name = "";
			m_on_error_goto_syntax = "";
			m_body = NULL;
		}

		syntax_entry( string name, string on_error, syntax_compound *body )
		{
			m_name = name;
			m_on_error_goto_syntax = on_error;
			m_body = body;
		}

		virtual ~syntax_entry()
		{
			if( m_body != NULL )
				delete m_body;
			m_name = "";
			m_on_error_goto_syntax = "";
			m_body = NULL;
		}

	// inherit
	public:
		virtual syntax_type get_type();
		virtual string to_string();
		
		virtual bool parse( parse_info *info );
		virtual bool reparse( parse_info *info );
		virtual bool can_accept_more( parse_para *para );
		virtual bool should_accept_more( parse_para *para );

	// common
	public:
		string get_name()
		{
			return m_name;
		}

		void set_name( string name )
		{
			m_name = name;
		}

		string get_on_error_goto_syntax()
		{
			return m_on_error_goto_syntax;
		}

		void set_on_error_goto_syntax( string on_error )
		{
			m_on_error_goto_syntax = on_error;
		}

		syntax_compound* get_body()
		{
			return m_body;
		}

		void set_body( syntax_compound *body )
		{
			if( m_body != NULL )
				delete m_body;
			m_body = body;
		}

	protected:
		virtual bool do_parse( parse_para *para, syntax *syn, parse_info *child_info );
		virtual bool do_reparse( parse_para *para, syntax *syn, parse_info *child_info );

	private:
		string m_name;
		string m_on_error_goto_syntax;
		syntax_compound *m_body;
	};

}

#endif // __syntax_entry_h__
